package com.hoongs.v1.handler;

import com.hoongs.v1.utils.Result;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常处理
 *
 */
@Component
@RestControllerAdvice
public class MyExceptionHandler {

    @ExceptionHandler
    public Result runtimeExceptionHnadler(Exception e){
        System.err.println(e);
        String msg = e.getMessage();
//        String msg = "服务器响应失败！";
        return Result.opError(msg);
    }
}